package com.zeroxml.cms.web.action.cms;

import net.sourceforge.stripes.integration.spring.SpringBean;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.UrlBinding;
import com.zeroxml.cms.service.IArticleService;
import com.zeroxml.cms.service.ICatalogService;
import com.zeroxml.cms.bo.Article;
import com.zeroxml.cms.bo.Catalog;
import com.zeroxml.cms.web.action.BaseAction;
import com.wyvoid.core.persistent.hibernate.HibernatePage;

/**
 * User: cjp
 * Date: 2007-9-16
 * Time: 21:52:01
 */
@UrlBinding("/tool.do")
public class ToolAction extends BaseAction {
    @SpringBean
    IArticleService articleService;
    @SpringBean
    ICatalogService catalogService;
    HibernatePage<Article> articles;
    private int curPage;

    public void setArticleService(IArticleService articleService) {
        this.articleService = articleService;
    }

    public HibernatePage<Article> getArticles() {
        return articles;
    }

    public void setCurPage(int curPage) {
        this.curPage = curPage;
    }

    @DefaultHandler
    public Resolution tool() {
        Catalog catalog = catalogService.getCatalog("tool");
        if (catalog != null) {
            int pageSize = 20;
            articles = articleService.findArticles(catalog.getId(),null, curPage, pageSize);
        }
        return getCmsResolution("tool/tool");
    }
}
